package com.happy3w.bean.json;

public class StringDecoder {
    private boolean inString = false;
    private boolean escaped = false;

    public Character accept(char in) {
        if (escaped) {
            escaped = false;
            return in;
        }
        if (in == '\\') {
            escaped = true;
            return null;
        }
        if (in == '"') {
            if (inString) {
                inString = false;
                return null;
            } else {
                inString = true;
                return null;
            }
        }
        return inString? in : null;
    }

    public boolean inString() {
        return inString;
    }
}
